from boot import MessageBoxBase, QVBoxLayout, Qt, QLabel, QSizePolicy, GlobalWidget, QWidget, Union, QGridLayout
from view.widget.qq9_label import QQ9FromTitle


__all__ = ["QQ9MessageBox", "QQ9MessageBoxWidget", "QQ9TipsMessageWidget"]


class QQ9MessageBox(MessageBoxBase):

    def __init__(self,
                     title: str = "",
                     width: int = 400,
                     height: int = 300
                 ):
        super().__init__(parent=GlobalWidget.root)

        # 设置内容窗口尺寸
        self.widget.setFixedSize(width, height)

        # 设置窗口标题
        self.title_label = QLabel(self.widget)
        self.title_label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
        self.title_label.setText(title)
        self.title_label.setFixedSize(width - 2, 40)
        self.title_label.setAlignment(Qt.AlignCenter)
        self.title_label.setStyleSheet(
            """
            QLabel {
                font-family: "微软雅黑";
                font-size: 14px;
                color: #555555;
                background: transparent;
                border: none;
                border-bottom: 1px solid #F5F5F5;
            }
            """
        )
        self.title_label.move(1, 0)


class QQ9MessageBoxWidget(QWidget):

    def __init__(self,
                    parent: Union[QWidget, None] = None,
                    add: bool = False,
                 ):
        super().__init__(parent=parent.widget)

        self.setContentsMargins(30, 0, 30, 0)
        self.setFixedSize(parent.widget.width() - 2, parent.widget.height() - 90)
        self.move(1, 40)

        self.main_g_layout = QGridLayout()
        self.setLayout(self.main_g_layout)

    def set_info(self):
        pass


class QQ9TipsMessageWidget(QWidget):

    def __init__(self,
                 parent: Union[QWidget, None] = None,
                 text: str = "",
                 ):
        super().__init__(parent=parent.widget)

        self.setContentsMargins(30, 0, 30, 0)
        self.setFixedSize(parent.widget.width() - 2, parent.widget.height() - 90)
        self.move(1, 40)

        self.message_label = QQ9FromTitle(self)
        self.message_label.setText(text)
        self.message_label.move(20, 15)